[id].vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. <template>
  2. <div id="newsList">
  3. <!-- 页面头部 -->
  4. <HomePageHead></HomePageHead>
  5. <!-- Banner1 -->
  6. <HomeBanner1></HomeBanner1>
  7. <!-- 面包屑导航 -->
  8. <div class="breadcrumb">
  9. <div class="inner">
  10. <span class="location">当前位置:</span>
  11. <el-breadcrumb :separator-icon="ArrowRight">
  12. <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
  13. <el-breadcrumb-item :to="{ path: '/newsList' }">{{ name }}</el-breadcrumb-item>
  14. </el-breadcrumb>
  15. </div>
  16. </div>
  17. <!-- 资讯列表 -->
  18. <div class="newsList">
  19. <div class="inner">
  20. <div class="innerLeft">
  21. <ul class="list">
  22. <li v-for="(item, index) in newsList" :key="index">
  23. <NuxtLink :to="{ path: `/speciaArticle/${item.id}`}" target="_blank">{{ item.list_title }}</NuxtLink>
  24. </li>
  25. </ul>
  26. <!-- 分页器 -->
  27. <div class="pagination">
  28. <el-pagination size="small" background layout="prev, pager, next" :total="total" class="mt-4"
  29. prev-text="上一页" next-text="下一页" @change="changePage" />
  30. <!-- <HomePagination @sendData="handleData"></HomePagination> -->
  31. </div>
  32. </div>
  33. <div class="innerRight">
  34. <DetailHotNews></DetailHotNews>
  35. </div>
  36. </div>
  37. </div>
  38. <!-- 三农资讯logo -->
  39. <HomeSannongzixun></HomeSannongzixun>
  40. <!-- 资讯推荐 -->
  41. <div class="zixuntuijian">
  42. <div class="inner">
  43. <div class="innerLeft">
  44. <div class="zixunLeft">
  45. <!-- 标题部分 -->
  46. <div class="title">
  47. <h3>
  48. 资讯推荐
  49. <!-- <span>查看更多</span> -->
  50. </h3>
  51. </div>
  52. <!-- 图片和文字列表 -->
  53. <ul class="photo_text">
  54. <li v-for="item in news1">
  55. <img :src="item.imgurl" alt="">
  56. <div>
  57. <h5>{{ item.title }}</h5>
  58. <p>
  59. <span>{{ item.author }}</span>
  60. <span>{{ item.created_at }}</span>
  61. </p>
  62. </div>
  63. </li>
  64. <li v-for="item in news11">
  65. <em></em>
  66. {{ item.title }}
  67. </li>
  68. </ul>
  69. </div>
  70. <div class="zixunRight">
  71. <!-- 标题部分 -->
  72. <div class="title">
  73. <h3>
  74. 资讯推荐
  75. <!-- <span>查看更多</span> -->
  76. </h3>
  77. </div>
  78. <!-- 图片和文字列表 -->
  79. <ul class="photo_text">
  80. <li v-for="item in news2">
  81. <img :src="item.imgurl" alt="">
  82. <div>
  83. <h5>{{ item.title }}</h5>
  84. <p>
  85. <span>{{ item.author }}</span>
  86. <span>{{ item.created_at }}</span>
  87. </p>
  88. </div>
  89. </li>
  90. <li v-for="item in news22">
  91. <em></em>
  92. {{ item.title }}
  93. </li>
  94. </ul>
  95. </div>
  96. </div>
  97. <div class="innerRight">
  98. <!-- 标题部分 -->
  99. <div class="title">
  100. <h4>
  101. 热点资讯
  102. <!-- <span>查看更多</span> -->
  103. </h4>
  104. </div>
  105. <!-- 列表 -->
  106. <ul class="rightList">
  107. <li v-for="item in hotlistall">
  108. <img class="left" :src="item.imgurl">
  109. <p class="left">{{ item.title }}</p>
  110. </li>
  111. </ul>
  112. </div>
  113. </div>
  114. </div>
  115. <!-- 页面底部 -->
  116. <HomeFoot></HomeFoot>
  117. </div>
  118. </template>
  119. <script setup>
  120. import { onMounted } from 'vue';
  121. import { ElBreadcrumb, ElBreadcrumbItem, ElPagination } from 'element-plus'
  122. import { ArrowRight } from '@element-plus/icons-vue'
  123. const nuxtApp = useNuxtApp();
  124. const axios = nuxtApp.$axios;
  125. //获得跳转过来的id
  126. const route = useRoute();
  127. const pageId = route.params.id; //获得该页面的id
  128. console.log(pageId);
  129. onMounted(() => {
  130. })
  131. let changePage = (value) => {
  132. console.log("当前页码", value);
  133. page.value = value
  134. console.log(page.value);
  135. newslists()
  136. }
  137. // 新闻列表
  138. const newsList = useState("newsList", () => '');
  139. const newslists = async () => {
  140. try {
  141. const response = await axios.get(`/web/getWebsiteFooterCategoryList?fcat_id=${pageId}`);
  142. // console.log(response.data.rows);
  143. newsList.value = response.data;
  144. //total.value = response.data.count;
  145. } catch (error) {
  146. console.error(error);
  147. }
  148. }
  149. //热点资讯
  150. const hotlistall = useState("hotlistall", () => "");
  151. const hotlist = async () => {
  152. try {
  153. const response = await axios.get(`/web/getWebsiteArticlett?pageSize=${2}&level=${4}&placeid=${1}`);
  154. console.log('热点资讯', response.data);
  155. for (let item of response.data) {
  156. console.log(item);
  157. item.count = 1;
  158. }
  159. hotlistall.value = response.data;
  160. } catch (error) {
  161. console.error(error);
  162. }
  163. }
  164. //资讯推荐1
  165. const news1 = useState("news1", () => "");
  166. const newslist1 = async () => {
  167. try {
  168. const response = await axios.get(`/web/getWebsiteArticlett?pageSize=${1}&level=${5}&placeid=${1}`);
  169. console.log('热点资讯', response.data);
  170. news1.value = response.data;
  171. } catch (error) {
  172. console.error(error);
  173. }
  174. }
  175. const news11 = useState("news11", () => "");
  176. const newslist11 = async () => {
  177. try {
  178. const response = await axios.get(`/web/getWebsiteArticlett?pageSize=${3}&level=${5}&placeid=${1}`);
  179. console.log('热点资讯', response.data);
  180. news11.value = response.data;
  181. } catch (error) {
  182. console.error(error);
  183. }
  184. }
  185. //资讯推荐2
  186. const news2 = useState("news2", () => "");
  187. const newslist2 = async () => {
  188. try {
  189. const response = await axios.get(`/web/getWebsiteArticlett?pageSize=${1}&level=${5}&placeid=${1}`);
  190. console.log('热点资讯', response.data);
  191. news2.value = response.data;
  192. } catch (error) {
  193. console.error(error);
  194. }
  195. }
  196. const news22 = useState("news22", () => "");
  197. const newslist22 = async () => {
  198. try {
  199. const response = await axios.get(`/web/getWebsiteArticlett?pageSize=${3}&level=${5}&placeid=${1}`);
  200. console.log('热点资讯', response.data);
  201. news22.value = response.data;
  202. } catch (error) {
  203. console.error(error);
  204. }
  205. }
  206. //挂载成功钩子函数
  207. onMounted(() => {
  208. // 资讯推荐
  209. newslists()
  210. // 热点资讯
  211. hotlist()
  212. // 资讯推荐
  213. newslist1()
  214. newslist2()
  215. // 热点资讯
  216. newslist11()
  217. newslist22()
  218. })
  219. //路由中间件
  220. definePageMeta({
  221. middleware: 'auth'
  222. })
  223. </script>
  224. <style lang="less" scoped>
  225. //导航条
  226. .breadcrumb {
  227. width: 100%;
  228. height: 22px;
  229. margin-bottom: 30px;
  230. font-family: Microsoft YaHei, Microsoft YaHei;
  231. font-weight: 400;
  232. font-size: 20px;
  233. color: #666666;
  234. line-height: 23px;
  235. text-align: left;
  236. font-style: normal;
  237. text-transform: none;
  238. :deep(.el-breadcrumb) {
  239. display: inline-block;
  240. vertical-align: -4px;
  241. }
  242. :deep(.el-breadcrumb__inner a),
  243. :deep(.el-breadcrumb__inner.is-link) {
  244. color: #666666;
  245. font-weight: 400;
  246. text-decoration: none;
  247. transition: var(--el-transition-color);
  248. }
  249. span {
  250. font-family: Microsoft YaHei, Microsoft YaHei;
  251. font-weight: 400;
  252. font-size: 20px;
  253. color: #666666;
  254. line-height: 23px;
  255. text-align: left;
  256. font-style: normal;
  257. text-transform: none;
  258. }
  259. span:hover {
  260. color: #666666;
  261. }
  262. .location {
  263. margin-right: 20px;
  264. width: 100px;
  265. height: 22px;
  266. font-family: Microsoft YaHei, Microsoft YaHei;
  267. font-weight: 400;
  268. font-size: 20px;
  269. color: #666666;
  270. line-height: 23px;
  271. text-align: left;
  272. font-style: normal;
  273. text-transform: none;
  274. }
  275. }
  276. // 资讯列表
  277. .newsList {
  278. width: 100%;
  279. height: 675px;
  280. margin-bottom: 70px;
  281. .inner {
  282. width: 1200px;
  283. .innerLeft,
  284. .innerRight {
  285. border-top: 1px solid #139602;
  286. }
  287. .innerLeft {
  288. height: 675px;
  289. >.list {
  290. height: 570px;
  291. margin-bottom: 70px;
  292. >li {
  293. width: 790px;
  294. height: 56px;
  295. white-space: nowrap;
  296. overflow: hidden;
  297. text-overflow: ellipsis;
  298. line-height: 56px;
  299. border-bottom: 1px solid #D9D9D9;
  300. >a {
  301. width: 360px;
  302. height: 26px;
  303. font-family: Microsoft YaHei, Microsoft YaHei;
  304. font-weight: 400;
  305. font-size: 20px;
  306. color: #333333;
  307. line-height: 26px;
  308. text-align: left;
  309. font-style: normal;
  310. text-transform: none;
  311. }
  312. }
  313. >li:hover>a {
  314. color: #139602;
  315. }
  316. >li:nth-child(1)::after,
  317. >li:nth-child(2)::after {
  318. content: "热";
  319. margin-left: 13px;
  320. background: #FF8A37;
  321. color: #fff;
  322. font-size: 14px;
  323. padding: 0px 2px;
  324. }
  325. }
  326. >.pagination {
  327. width: 800px;
  328. height: 34px;
  329. margin-left: 141px;
  330. display: flex;
  331. justify-content: center;
  332. margin: 0;
  333. // 鼠标移入后字体颜色
  334. .el-pagination::v-deep :hover {
  335. color: #139609;
  336. }
  337. .el-pagination.is-background::v-deep .btn-next,
  338. .el-pagination.is-background::v-deep .btn-prev {
  339. width: 70px;
  340. height: 34px;
  341. margin: 0px 10px;
  342. border-radius: 4px;
  343. }
  344. .el-pagination.is-background::v-deep .el-pager li {
  345. margin: 0px 10px;
  346. width: 38px;
  347. height: 34px;
  348. border-radius: 4px;
  349. }
  350. .el-pagination.is-background::v-deep .btn-next.is-active,
  351. .el-pagination.is-background::v-deep .btn-prev.is-active,
  352. .el-pagination.is-background::v-deep .el-pager li.is-active {
  353. background-color: #028e21;
  354. color: #fff;
  355. }
  356. }
  357. }
  358. .innerRight {
  359. width: 381px;
  360. height: 605px;
  361. }
  362. }
  363. }
  364. //资讯推荐
  365. .zixuntuijian {
  366. width: 100%;
  367. height: 290px;
  368. margin-bottom: 70px;
  369. .innerLeft {
  370. // 左侧
  371. .zixunLeft {
  372. margin-right: 30px;
  373. }
  374. .zixunRight,
  375. .zixunLeft {
  376. float: left;
  377. width: 380px;
  378. height: 290px;
  379. // 标题部分
  380. >.title {
  381. width: 380px;
  382. }
  383. >.title>h3 {
  384. height: 36px;
  385. font-family: Source Han Sans, Source Han Sans;
  386. font-weight: bold;
  387. font-size: 24px;
  388. color: #000000;
  389. line-height: 28px;
  390. text-align: left;
  391. font-style: normal;
  392. text-transform: none;
  393. border-bottom: 1px solid #139602;
  394. }
  395. >.title>h3>span {
  396. float: right;
  397. width: 56px;
  398. height: 20px;
  399. line-height: 24px;
  400. font-weight: 400;
  401. font-size: 14px;
  402. color: #999999;
  403. font-style: normal;
  404. text-transform: none;
  405. }
  406. .photo_text {
  407. >li:first-child {
  408. width: 380px;
  409. height: 120px;
  410. margin-top: 20px;
  411. margin-bottom: 15px;
  412. position: relative;
  413. >img {
  414. float: left;
  415. width: 160px;
  416. height: 120px;
  417. }
  418. >div {
  419. float: left;
  420. width: 220px;
  421. height: 120px;
  422. padding-left: 15px;
  423. padding-top: 6px;
  424. box-sizing: border-box;
  425. background-color: #f6f6f6;
  426. >h5 {
  427. width: 200px;
  428. height: 54px;
  429. display: -webkit-box;
  430. -webkit-box-orient: vertical;
  431. -webkit-line-clamp: 2;
  432. overflow: hidden;
  433. text-overflow: ellipsis;
  434. word-break: break-all;
  435. font-family: Source Han Sans, Source Han Sans;
  436. font-weight: 500;
  437. font-size: 18px;
  438. color: #333333;
  439. line-height: 26px;
  440. text-align: left;
  441. font-style: normal;
  442. text-transform: none;
  443. }
  444. >p {
  445. width: 200px;
  446. height: 22px;
  447. line-height: 20px;
  448. position: absolute;
  449. bottom: 5px;
  450. right: 0;
  451. >span {
  452. display: inline-block;
  453. // width: 100px;
  454. height: 18px;
  455. font-family: Source Han Sans, Source Han Sans;
  456. font-weight: 400;
  457. font-size: 12px;
  458. color: #999999;
  459. text-align: left;
  460. line-height: 14px;
  461. font-style: normal;
  462. text-transform: none;
  463. }
  464. >span:last-child {
  465. // width: 90px;
  466. text-align: right;
  467. margin-left: 20px;
  468. }
  469. }
  470. }
  471. }
  472. >li {
  473. width: 380px;
  474. height: 25px;
  475. white-space: nowrap;
  476. overflow: hidden;
  477. text-overflow: ellipsis;
  478. font-family: PingFang SC, PingFang SC;
  479. font-weight: 500;
  480. font-size: 18px;
  481. color: #333333;
  482. line-height: 21px;
  483. text-align: left;
  484. font-style: normal;
  485. text-transform: none;
  486. margin-bottom: 10px;
  487. em {
  488. display: inline-block;
  489. width: 8px;
  490. height: 8px;
  491. border-radius: 8px;
  492. margin-right: 10px;
  493. background-color: #d9d9d9;
  494. }
  495. }
  496. >li:hover {
  497. color: #139602;
  498. }
  499. >li:hover em {
  500. background-color: #139602;
  501. }
  502. }
  503. }
  504. }
  505. .innerRight {
  506. width: 381px;
  507. height: 290px;
  508. background-color: #fbfbfb;
  509. >.title {
  510. width: 380px;
  511. height: 40px;
  512. line-height: 40px;
  513. border-top: 1px solid #139602;
  514. border-bottom: 1px solid #e7e7e7;
  515. >h4 {
  516. font-family: Microsoft YaHei, Microsoft YaHei;
  517. font-weight: 400;
  518. margin-left: 20px;
  519. font-size: 20px;
  520. color: #000000;
  521. text-align: left;
  522. font-style: normal;
  523. text-transform: none;
  524. >span {
  525. float: right;
  526. font-family: Microsoft YaHei, Microsoft YaHei;
  527. font-weight: 400;
  528. font-size: 14px;
  529. margin-right: 10px;
  530. color: #999999;
  531. text-align: left;
  532. font-style: normal;
  533. text-transform: none;
  534. }
  535. }
  536. }
  537. .rightList {
  538. height: 540px;
  539. margin-top: 20px;
  540. >li {
  541. height: 100px;
  542. margin-bottom: 10px;
  543. >img {
  544. width: 150px;
  545. height: 100px;
  546. }
  547. >p {
  548. width: 219px;
  549. height: 100px;
  550. padding-left: 12px;
  551. font-family: PingFang SC, PingFang SC;
  552. font-weight: 400;
  553. font-size: 16px;
  554. color: #333333;
  555. line-height: 22px;
  556. text-align: left;
  557. font-style: normal;
  558. text-transform: none;
  559. }
  560. >p:hover {
  561. box-shadow: 0 0 16px 1px rgba(0, 0, 0, 0.1);
  562. }
  563. }
  564. }
  565. }
  566. }
  567. </style>